import sys
from PySide2 import QtCore, QtWidgets,QtGui
import ui_qt1
from PySide2.QtCore import Slot
from numpy import arange,sin,cos
from PySide2.QtCharts import *
# print(dir(numpy))
class dlgqt1(QtWidgets.QDialog):
    ui=ui_qt1.Ui_qt1Class();
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui.setupUi(self)
        self.x = arange(0, 10.0, 10.0/27)
        self.y1 = sin(self.x)
        self.y2=2*cos(self.x)
        self.curve1 =  QtCharts.QLineSeries()
        self.curve2 =  QtCharts.QLineSeries()
                              
        for i in range(len(self.x)):
            self.curve1.append(self.x[i], self.y1[i])
            self.curve2.append(self.x[i], self.y2[i])
        self.chart = QtCharts.QChart()
        self.chart.addSeries(self.curve1)
        self.chart.addSeries(self.curve2)
        self.chart.createDefaultAxes()
        # self.chart.setTitle('QtCharts Test')

        # self.axis_x = QtCharts.QValueAxis()
        # self.axis_x.setLabelFormat('%.1f')
        # self.axis_x.setTitleText('X')
        # self.axis_x.setTickCount(11)
        # self.axis_x.setMinorTickCount(4)
        # self.chart.addAxis(self.axis_x,QtCore.Qt.AlignBottom)
        # self.curve1.attachAxis(self.axis_x)
        # self.curve2.attachAxis(self.axis_x)
        # self.axis_y = QtCharts.QValueAxis()
        # self.axis_y.setLabelFormat('%.1f')
        # self.axis_y.setTitleText('Y')
        # self.chart.addAxis(self.axis_y, QtCore.Qt.AlignLeft)
        # self.curve1.attachAxis(self.axis_y)
        # self.curve2.attachAxis(self.axis_y)
        self.chart_view = QtCharts.QChartView(self.chart, self)

        self.horizontalLayout =QtWidgets.QHBoxLayout(self.ui.frame)
        self.horizontalLayout.addWidget(self.chart_view)

        self.ui.pushButton_in.clicked.connect(self.on_pushButton_in_clicked)
        self.ui.pushButton_out.clicked.connect(self.on_pushButton_out_clicked)
        self.ui.pushButton_reset.clicked.connect(self.on_pushButton_reset_clicked)
    def on_pushButton_out_clicked(self):
        print("zoomOut")
        self.chart.zoomOut()                                                                                   
    def on_pushButton_in_clicked(self):
        print("zoomIn")
        self.chart.zoomIn()                                                                           
    def on_pushButton_reset_clicked(self):
        print("zoomReset")
        self.chart.zoomReset()
if __name__ == "__main__":
    from PySide2 import QtCore, QtWidgets
    import sys
    a = QtWidgets.QApplication(sys.argv)
    a.lastWindowClosed.connect(a.quit)
    w =dlgqt1()
    w.show()
    sys.exit(a.exec_())